﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Web.Google
{
    public class ColorChooser
    {
        #region Fields

        private List<Color> colors = new List<Color>();

        #endregion

        #region Constructors

        public ColorChooser()
        {
        }

        public ColorChooser(params Color[] colors)
        {
            this.colors.AddRange((IEnumerable<Color>)colors);
        }

        public ColorChooser(IEnumerable<Color> colors)
        {
            this.colors.AddRange(colors);
        }

        #endregion

        #region Properties

        public static ColorChooser Default
        {
            get
            {
                return new ColorChooser(
                    Color.FromArgb(29, 89, 186),
                    Color.FromArgb(193, 45, 0),
                    Color.FromArgb(59, 169, 187),
                    Color.FromArgb(107, 194, 35),
                    Color.FromArgb(234, 171, 59),
                    Color.FromArgb(179, 154, 238),
                    Color.FromArgb(26, 127, 144),
                    Color.FromArgb(249, 106, 68),
                    Color.FromArgb(145, 201, 209),
                    Color.FromArgb(22, 72, 80),
                    Color.FromArgb(35, 107, 224),
                    Color.FromArgb(199, 252, 153),
                    Color.FromArgb(105, 29, 182),
                    Color.FromArgb(255, 228, 163),
                    Color.FromArgb(210, 46, 209)
                    );
            }
        }

        public List<Color> Colors
        {
            get { return colors; }
        }

        #endregion

        public virtual Color GetColor(int index)
        {
            if (colors.Count == 0)
            {
                ColorChooser d = Default;
                return d.GetColor(index);
            }
            else
            {
                if (index >= colors.Count)
                    index = (index % colors.Count);
                return colors[index];
            }
        }
    }
}